import request from './request.js'
// import qs from 'qs'
const baseUrl = 'http://localhost:9999'
// 登录
export function Login (params) {
  return request({
    url: baseUrl + '/user/login',
    method: 'post',
    data: params
  })
}
// 注销
export function Logout () {
  return request({
    url: baseUrl + '/user/logout',
    method: 'get'
  })
}
// 发送邮箱验证码
export function mail (mail) {
  return request({
    url: baseUrl + '/user/mail',
    method: 'get',
    params: {
      mail: mail
    }
  })
}

// 修改密码
export function changePwd (params) {
  return request({
    url: baseUrl + '/user/changePwd',
    method: 'post',
    data: params
  })
}
// 获取验证码
export function getVcode () {
  return request({
    url: baseUrl + '/user/vcode',
    method: 'get'
  })
}
// 获取角色目录
export function getRoleList () {
  return request({
    url: baseUrl + '/role/roleList',
    method: 'get'
  })
}
// 添加和修改用户
export function addOrUpdate (params) {
  return request({
    url: baseUrl + '/user/addOrUpdate',
    method: 'post',
    data: params
  })
}

// 获取用户列表
export function getAllUser (params) {
  return request({
    url: baseUrl + '/user/getAllUser',
    method: 'post',
    data: params
  })
}

// 删除用户
export function delUser (id) {
  return request({
    url: baseUrl + '/user/delUser',
    method: 'get',
    params: {
      id: id
    }
  })
}

// 根据用户id查对应角色
export function getRoleById () {
  return request({
    url: baseUrl + '/role/getRoleById',
    method: 'get'
  })
}

// 根据用户id查相应部门
export function getDepartById () {
  return request({
    url: baseUrl + '/depart/getDepartById',
    method: 'get'
  })
}
// 获取部门列表
export function getDepartList () {
  return request({
    url: baseUrl + '/depart/getDepartList',
    method: 'get'
  })
}

// 获取角色列表
export function getAllRole () {
  return request({
    url: baseUrl + '/role/getRoleList',
    method: 'get'
  })
}

// 获取所有权限
export function getPermList (roleId) {
  return request({
    url: baseUrl + '/perm/getPermList',
    method: 'get',
    params: {
      roleId: roleId
    }
  })
}

// 设置角色权限
export function setPermByroleId (params) {
  return request({
    url: baseUrl + '/perm/setPermByRoleId',
    method: 'post',
    data: params
  })
}

// 根据角色id查所拥有的权限
export function getPermListByRoleId (roleId) {
  return request({
    url: baseUrl + '/perm/getPermListByRoleId',
    method: 'get',
    params: {
      roleId: roleId
    }
  })
}

// 查询所有请假记录
export function getLeaveList (params) {
  return request({
    url: baseUrl + '/leave/getLeaveList',
    method: 'post',
    data: params
  })
}

// 撤销请假申请
export function deleteLeave (leaveId) {
  return request({
    url: baseUrl + '/leave/deleteLeave',
    method: 'get',
    params: {
      leaveId: leaveId
    }
  })
}

// 提交请假申请
export function addLeave (params) {
  return request({
    url: baseUrl + '/leave/addLeave',
    method: 'post',
    data: params
  })
}

// 查询全部出差记录
export function getBusinessTripList (params) {
  return request({
    url: baseUrl + '/businessTrip/getBusinessTripList',
    method: 'post',
    data: params
  })
}
// 根据部门Id查出差记录
export function leaderGetBusinessTripList (params) {
  return request({
    url: baseUrl + '/businessTrip/leaderGetBusinessTripList',
    method: 'post',
    data: params
  })
}
// 根据userId查出差记录
export function employeeGetBusinessTripList (params) {
  return request({
    url: baseUrl + '/businessTrip/employeeGetBusinessTripList',
    method: 'post',
    data: params
  })
}
// 提交出差申请
export function addBusinessTrip (params) {
  return request({
    url: baseUrl + '/businessTrip/addBusinessTrip',
    method: 'post',
    data: params
  })
}
// 删除出差记录
export function deleteBusinessTrip (businessTripId) {
  return request({
    url: baseUrl + '/businessTrip/deleteBusinessTrip',
    method: 'get',
    params: {
      businessTripId: businessTripId
    }
  })
}
// 审核请假
export function examineLeave (params) {
  return request({
    url: baseUrl + '/leave/examineLeave',
    method: 'post',
    data: params
  })
}
// 审核出差
export function examineBusinessTrip (params) {
  return request({
    url: baseUrl + '/businessTrip/examineBusinessTrip',
    method: 'post',
    data: params
  })
}
// 签到
export function attendanceOn (params) {
  return request({
    url: baseUrl + '/attendance/on',
    method: 'post',
    data: params
  })
}
// 签退
export function attendanceOff (params) {
  return request({
    url: baseUrl + '/attendance/off',
    method: 'post',
    data: params
  })
}

// 考勤个人查询
export function getAttendanceForOne (params) {
  return request({
    url: baseUrl + '/attendance/getAttendanceForOne',
    method: 'post',
    data: params
  })
}
// 考勤全部查询
export function getAttendanceForAll (params) {
  return request({
    url: baseUrl + '/attendance/getAttendanceForAll',
    method: 'post',
    data: params
  })
}

// 条件查询部门列表
export function getDepartListWithCondition (params) {
  return request({
    url: baseUrl + '/depart/getDepartListWithCondition',
    method: 'post',
    data: params
  })
}

// 查询所有领导
export function getDepartLeader () {
  return request({
    url: baseUrl + '/user/getDepartLeader',
    method: 'get'
  })
}
// 添加或修改部门
export function addOrUpdateDepart (params) {
  return request({
    url: baseUrl + '/depart/addOrUpdateDepart',
    method: 'post',
    data: params
  })
}
// 提醒未读
export function hasEvent (userId) {
  return request({
    url: baseUrl + '/message/hasEvent',
    method: 'get',
    params: {
      userId: userId
    }
  })
}

// 清楚未读
export function clearUnreadMsg (userId) {
  return request({
    url: baseUrl + '/message/clearUnreadMsg',
    method: 'get',
    params: {
      userId: userId
    }
  })
}

// 获取当月总考勤信息
export function getTotalAttendance (month) {
  return request({
    url: baseUrl + '/attendance/getTotalAttendance',
    method: 'get',
    params: {
      month: month
    }
  })
}

// 统计某月请假信息
export function leaveReport (params) {
  return request({
    url: baseUrl + '/leave/leaveReport',
    method: 'post',
    data: params
  })
}
// 统计某月出差信息
export function businessTripReport (params) {
  return request({
    url: baseUrl + '/businessTrip/businessTripReport',
    method: 'post',
    data: params
  })
}
// 修改系统请假次数、最大迟到早退次数
export function alterSystemTime (leTime, leaveTime) {
  return request({
    url: baseUrl + '/system/alterSystemTime',
    method: 'get',
    params: {
      leTime: leTime,
      leaveTime: leaveTime
    }
  })
}
// 查询系统表
export function getSystemTime () {
  return request({
    url: baseUrl + '/system/getSystemTime',
    method: 'get'
  })
}

// 迟到冠军、早退冠军
export function getMostLate (month) {
  return request({
    url: baseUrl + '/attendance/getMostLate',
    method: 'get',
    params: {
      month: month
    }
  })
}

export function getMostEarly (month) {
  return request({
    url: baseUrl + '/attendance/getMostEarly',
    method: 'get',
    params: {
      month: month
    }
  })
}
